package com.final_project.zombiemenace.custom.view;


import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.final_project.zombiemenace.R;

public class CustomProgressBar extends RelativeLayout{

	private static final int DEFAULT_PROGRESS_MAX = 100;
	private TextView progressText;
	private ProgressBar progressBar;
	
	
	public CustomProgressBar(Context context, AttributeSet attr) {
		super(context,attr);
		initLayout();
		initMemebers();
	}
	
	private void initLayout(){
		LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		inflater.inflate(R.layout.custom_view_progress_bar, this, true);
	}
	
	private void initMemebers(){
		progressText = (TextView)findViewById(R.id.progress_text);
		progressBar = (ProgressBar) findViewById(R.id.progress_bar);
		progressBar.setMax(DEFAULT_PROGRESS_MAX);
		setText();
	}
	
	public int getMax(){
		return progressBar.getMax();
	}
	public void setMax(int max){
		progressBar.setMax(max);
	}
	
	public void setProgress(int progress){
		progressBar.setProgress(progress);
	}
	
	public int getProgress(){
		return progressBar.getProgress();
	}
	
	private void setText(){
		String loading = getResources().getString(R.string.loading);
		progressText.setText(loading);
	}

}
